from fastapi import FastAPI
from pydantic import BaseModel

class Item(BaseModel):
    name: str
    description: str | None = None
    price: float
    tax: float | None = None

app = FastAPI()

@app.put('/items/{item_id}')
async def update_item(item_id: int, item: Item, q: str | None = None):
    item_dict = item.dict()
    
    if item.tax:
        price_with_tax = item.price + item.tax
        item_dict.update({'price_with_tax': price_with_tax})
    result = {'item': item_id, **item_dict}
    if q:
        result.update({'q': q})

    return result